/*
 * Copyright (c) 2022 上海市政工程设计研究总院(集团)有限公司 All Rights Reserved.
 */
package com.smedi.ismedi.constructionproject.core.port.adapter.restful.convert;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smedi.ismedi.constructionproject.api.dto.request.*;
import com.smedi.ismedi.constructionproject.api.dto.response.FileResponse;
import com.smedi.ismedi.constructionproject.api.dto.response.ProjectApplyResponse;
import com.smedi.ismedi.constructionproject.api.dto.response.resp.ProjectDetailResp;
import com.smedi.ismedi.constructionproject.core.application.command.*;
import com.smedi.ismedi.constructionproject.core.application.query.vo.HrOrganizationVo;
import com.smedi.ismedi.constructionproject.core.application.query.vo.ProjectDetailVo;
import com.smedi.ismedi.constructionproject.core.domain.aggregatemodel.*;
import com.smedi.ismedi.constructionproject.core.domain.dto.PersonQuery;
import com.smedi.ismedi.constructionproject.core.port.adapter.persistence.model.ProjectApplyEntity;
import com.smedi.ismedi.constructionproject.core.port.adapter.persistence.model.ProjectAssignmentEntity;
import com.smedi.ismedi.constructionproject.core.port.adapter.persistence.model.ProjectBasicEntity;
import com.smedi.ismedi.file.dto.response.FileInfoResponse;
import com.smedi.ismedi.inmail.api.dto.request.ProcessInstanceStartRequest;
import com.smedi.ismedi.inmail.api.dto.request.ProcessTaskCompleteRequest;
import com.smedi.ismedi.inmail.api.dto.request.ProcessTaskListRequest;
import com.smedi.ismedi.inmail.api.dto.request.TaskRecordRequest;
import com.smedi.ismedi.inmail.api.dto.response.ProcessTaskResponse;
import com.smedi.ismedi.notification.api.dto.request.SendSmsRequest;
import com.smedi.ismedi.organization.api.dto.response.resp.OrganizationResp;
import com.smedi.ismedi.personnel.api.dto.request.PersonListQueryRequest;
import com.smedi.ismedi.personnel.api.dto.response.PersonSimpleResponse;
import com.smedi.ismedi.personnel.api.dto.response.resp.PersonResp;
import com.smedi.ismedi.web.starter.common.PaginationData;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;

import java.util.List;

/**
 * 维修内容 Infrastructure Converter
 *
 * @author 15428
 * &#064;date  2022-06-07 15:22:03
 * @since 0.0.1
 */
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface AdapterConverter {

    ProjectApplyCreateCommand createdRequestToCommand(ProjectApplyCreateRequest projectApplyCreateRequest);

    ProjectApplyEditCommand editRequestToCommand(ProjectApplyEditRequest projectApplyEditRequest);

    ProjectApplyResponse projectApplyToResponse(ProjectApply projectApply);

    List<ProjectApplyResponse> projectApplyListToResponseList(List<ProjectApply> projectApplies);

    @Mapping(source = "project.projectId", target = "projectId")
    @Mapping(source = "currentDealPerson.id", target = "currentDealPersonId")
    @Mapping(source = "applyPerson.id", target = "applyPersonId")
    ProjectApplyEntity projectApplyToEntity(ProjectApply projectApply);

    @Mapping(source = "projectId", target = "project.projectId")
    ProjectApply projectApplyEntityToProjectApply(ProjectApplyEntity projectApplyEntity);

    List<File> fileInfoResponseToFile(List<FileInfoResponse> fileInfoResponses);

    File fileInfoResponseToFile(FileInfoResponse fileInfoResponse);

    PersonListQueryRequest personQueryToPersonListQueryRequest(PersonQuery personQuery);

    List<Person> respToPerson(List<PersonResp> resps);

    @Mapping(source = "lastName", target = "name")
    Person personRespToPerson(PersonResp personResp);

    List<Person> personRespToPerson(List<PersonResp> personResps);


    @Mapping(source = "urlOut", target = "url")
    FileResponse fileToFileResponse(File file);

    List<Person> personSimpleResponsesToPersons(List<PersonSimpleResponse> personSimpleResponses);

    @Mapping(source = "personId", target = "id")
    @Mapping(source = "lastName", target = "name")
    Person personSimpleResponseToPerson(PersonSimpleResponse personSimpleResponse);

    ProcessInstanceStartRequest processInstanceStartCommandToProcessInstanceStartRequest(ProcessInstanceStartCommand processInstanceStartCommand);

    ProcessTask processTaskResponseToProcessTask(ProcessTaskResponse processTaskResponse);

    List<ProcessTask> processTaskResponsesToProcessTasks(List<ProcessTaskResponse> processTaskResponses);

    ProcessTaskCompleteRequest processTaskCompleteCommandToProcessTaskCompleteRequest(ProcessTaskCompleteCommand processTaskCompleteCommand);

    ProcessTaskListRequest processTaskListCommandToProcessTaskListRequest(ProcessTaskListCommand processTaskListCommand);

    ProcessInstituteLeaderApprovalCommand instituteLeaderRequestToCommand(ProcessInstituteLeaderApprovalRequest processInstituteLeaderApprovalRequest);

    ProcessEngineerApprovalCommand engineerApprovalToCommand(ProcessEngineerApprovalRequest processEngineerApprovalRequest);

    ProcessEngineeringLeaderApprovalCommand EngineeringLeaderRequestToCommand(ProcessEngineeringLeaderApprovalRequest processEngineeringLeaderApprovalRequest);

    ProcessGeneralInstituteLeaderApprovalCommand GeneralInstituteLeaderRequestToCommand(ProcessGeneralInstituteLeaderApprovalRequest processGeneralInstituteLeaderApprovalRequest);

    ProjectApplyListQuery projectApplyListRequestToListQuery(ProjectApplyListRequest projectApplyListRequest);

    ProjectApplyPageQuery projectApplyPageRequestToPageQuery(ProjectApplyPageRequest projectApplyPageRequest);

    PaginationData<ProjectApplyResponse> projectApplyPageToResponsePage(Page<ProjectApply> projectApplyPage);

    Page<ProjectApply> entityPageToPage(Page<ProjectApplyEntity> projectApplyEntityPage1);

    @Mapping(source = "mobiles", target = "receivers")
    SendSmsRequest sendMessageCommandToSendSmsRequest(MessageSendCommand messageSendCommand);

    TaskRecordRequest createCommandToTaskRecord(TaskRecordCreateCommand taskRecordCreateCommand);

    TaskRecordRequest editCommandToTaskRecord(TaskRecordEditCommand taskRecordEditCommand);

    ProjectAssignmentEditCommand projectAssignmentEditRequestToProjectAssignmentEditCommand(ProjectAssignmentEditRequest projectAssignmentEditRequest);

    ProjectAssignment projectAssignmentEditCommandToProjectAssignment(ProjectAssignmentEditCommand projectAssignmentEditCommand);

    ProjectAssignmentEntity projectAssignmentToProjectAssignmentEntity(ProjectAssignment projectAssignment);

    @Mapping(target = "projectManager", ignore = true)
    ProjectDetailVo projectToProjectDetailVo(Project project);

    HrOrganizationVo organizationRespToHrOrganizationVo(OrganizationResp organizationResps);

    List<HrOrganizationVo> organizationRespToHrOrganizationVo(List<OrganizationResp> organizationResps);

    Page<Project> projectEntityPageToProjectPage(Page<ProjectBasicEntity> projectBasicEntityPage);

    @Mapping(target = "records", ignore = true)
    Page<ProjectDetailVo> projectEntityPageToProjectDetailVoPage(Page<ProjectBasicEntity> projectBasicEntityPage);

    PaginationData<ProjectDetailResp> projectPageToProjectRespPaginationData(Page<ProjectDetailVo> projectPage);
    @Mapping(source = "projectId", target = "id")
    ProjectBasicEntity projectBasicToProjectBasicEntity(ProjectBasic projectBasic);
}
